package service.auth.impl;

import helper.enums.EnabledEnum;
import model.auth.Users;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import service.auth.UsersService;

import dao.mapper.auth.UsersCrudMapper;

@Service("auth.UsersService")
public class UsersServiceImpl implements UsersService {
	@Autowired
	@Qualifier("auth.UsersCrudMapper")
	private UsersCrudMapper usersCrudMapper;

	public int deleteById(Long id) {
		return usersCrudMapper.deleteById(id);
	}

	public Users getById(Long id) {		 
		return usersCrudMapper.getById(id);
	}

	public Users getValidById(Long id) {
		return usersCrudMapper.getValidById(id, EnabledEnum.ENABLED.getValue());
	}

	public void insert(Users model) {
		Long id = usersCrudMapper.selectKey();
		model.setId(id);
		usersCrudMapper.insert(model);
	}

}
